//
//  header.h
//  mcf
//
//  Created by yuike6 yuike6 on 12-1-5.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#ifndef mcf_header_h
#define mcf_header_h

/*     | code |       */
#import "SynthesizeSingleton.h"

/*     | database |       */
//#import "SQLiteKit.h"


/*     | business |       */
#import "Top.h"
#import "TopApi.h"
#import "TopApiDef.h"
#import "TOPHB.h"
#import "TopApiLogin.h"
#import "TopApiConvert.h"
#import "TopApiItemGet.h"
#import "TopApiTraderates.h"
#import "traderates_search_response.h"
#import "item_get_response.h"
#import "trade_rate.h"
#import "TopApiUserGet.h"
#import "TopApiUsersGet.h"
#import "user_get_response.h"
#import "TopUsers.h"



/*     | system |       */
#import "YkSystem.h"


/*     | json |       */
#import "CDataScanner.h"
#import "CDataScanner_Extensions.h"
#import "NSCharacterSet_Extensions.h"
#import "NSDictionary_JSONExtensions.h"
#import "NSScanner_Extensions.h"
#import "CJSONDataSerializer.h"
#import "CJSONDeserializer.h"
#import "CJSONScanner.h"
#import "CJSONSerializer.h"
#import "CSerializedJSONData.h"

/*     | ui |       */
#import "UIViewEx.h"
#import "UIView+Extend.h"
#import "UIView+RectSize.h"
#import "RichTextLabel.h"
#import "AsyncCacheImageView.h"
#import "Toast+UIView.h"
#import "FlashlightLabel.h"
#import "ImageSpinner.h"
#import "YPopTipView.h"
#import "YUIPageControl.h"
#import "LeveyHUD.h"
#import "Fliper.h"
#import "UITapGestureRecognizerEx.h"
#import "CheckBox.h"
#import "FXLabel.h"
#import "YFolders.h"
#import "YCommentView.h"
#import "YCommentModel.h"
#import "YSpreadView.h"
#import "UIControl+Category.h"
#import "CALayer+Additions.h"
#import "YLayerDelegateProxy.h"
#import "CALayerEx.h"
#import "UIScrollViewEx.h"
#import "LeveyWindowHUD.h"
#import "EGORefreshTableHeaderView.h"
#import "YAnimatedImagesView.h"
#import "LineView.h"
#import "ShapedView.h"
#import "TriangleView.h"
#import "EllipseView.h"
#import "RhombusView.h"
#import "RoundedPentagonView.h"
//#import "RoundedRectangleView.h"
//#import "UILabel+VerticalAlignment.h"

/*     | xml |       */
#import "XMLParser.h"
#import "XMLParsedElement.h"
#import "XMLParsedTree.h"

/*     | logger |       */
#import "Logger.h"
#import "Stopwatch.h"

/*     | task |       */
#import "YTask.h"
#import "YTaskDef.h"
#import "YTaskPool.h"
#import "YTaskResult.h"

/*     | animation |       */
#import "YkAnimationStep.h"
#import "YkAnimationSequence.h"

/*     | net |       */
#import "YkNetWork.h"
#import "NetworkActivityIndicator.h"
#import "HTTPUtil.h"
#import "HTTPParam.h"
#import "HTTPParamList.h"
#import "DownloadHelper.h"
#import "DownloadRecvData.h"
#import "NSURLConnection+Blocks.h"
#import "Reachability.h"
#import "YDownloaderHelper.h"
#import "DownloadRequest.h"

/*     | lang |       */
#import "NSData+Extension.h"
#import "NSString+Extension.h"
#import "Base64Transcoder.h"
#import "YFixSizeMutableDictionary.h"
#import "NSDate+Extension.h"
#import "NSArray+NSArrayExtension.h"
#import "NSObject+Extension.h"
#import "NSDictionary+Extension.h"

/*     | io |       */
#import "YPath.h"
#import "YFile.h"

/*     | color |       */
#import "YkColor.h"

/*     | UIImage |       */
#import "UIImage+Extensions.h"

/*     | minizip |       */
#import "YZip.h"

/*     | YMath |       */
#import "YMath.h"


/*     | weibo |       */
#import "YWeiboDef.h"



#define YRelease(obj)               [obj release]; obj = nil;
#define YLocalizedString(s)         NSLocalizedString(s,nil)  


#define BUTTON_FUNCTION(btn, function)    [btn addTarget:self action:@selector(function) forControlEvents:UIControlEventTouchUpInside];

#define CLASSNAME(cls)       [[cls class] description]

/*
 本地路径宏定义
 */
#define kDocuments                  [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
#define kTmp                        [NSHomeDirectory() stringByAppendingPathComponent:@"tmp"]
#define kLibrary                    [NSHomeDirectory() stringByAppendingPathComponent:@"Library"]
#define kLibraryCaches              [YPath Combine:kLibrary combinePath:@"Caches"]
#define kResource                   [[NSBundle mainBundle] resourcePath]


// 是否高清屏
#define isRetinaIphone ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
// 是否iPad
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
// 是否模拟器
#define isSimulator (NSNotFound != [[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location)

#define DELEGATE_CALLBACK(X, Y) if (self.delegate && [((NSObject*)self.delegate) respondsToSelector:@selector(X)]) [((NSObject*)self.delegate) performSelector:@selector(X) withObject:Y];

#define NUMBER(X) [NSNumber numberWithFloat:X]

#define YHIDEVIEW(v)     [v setHidden:TRUE];  [v setAlpha:0.0f];
#define YSHOWVIEW(v)     [v setHidden:FALSE]; [v setAlpha:1.0f];




#define _NOTIFICATION_FLIPER_NEW_PAGE_              @"notification_fliper_new_page"

#define kCache                    [kLibraryCaches stringByAppendingPathComponent:@"yuikeCache"]
#define kDownloadTempPath         [kCache stringByAppendingPathComponent:@"cache/download"]



CG_INLINE CGRect IntxFrame(CGRect frame) {
    frame.origin.x = (int)(frame.origin.x + 0.5);
    frame.origin.y = (int)(frame.origin.y + 0.5);
    frame.size.width = (int)(frame.size.width + 0.5);
    frame.size.height = (int)(frame.size.height + 0.5);
    return frame;
}
CG_INLINE CGSize IntxSize(CGSize size) {
    size.width = (int)(size.width + 0.5);
    size.height = (int)(size.height + 0.5);
    return size;
}
CG_INLINE CGPoint IntxPoint(CGPoint point) {
    point.x = (int)(point.x + 0.5);
    point.y = (int)(point.y + 0.5);
    return point;
}


typedef enum {
    ScrollDirectionUp,
    ScrollDirectionDown
    
} ScrollDirection;


#define CGPOINT_INVALID            CGPointMake(NAN, NAN)


/* 
 device token 上报使用的
 */
#define _DEVICE_TOKEN_                                  @"%%devicetoken%%"
#define _CHECK_SUM_                                     @"%%checksum%%"
#define _CHECK_SUM_ADD_STR_                             @" yuikemall3339598"



// 微博帐号 相关。
#define YUIKE_WEIBO_ID_SINA 2536169012 //if ([sinaWeibo isAuthorized]) { 
#define LIU_HAIFENG_ID_SINA 1704767664
#define YUIKE_WEIBO_ID_TENC 1// 程序内部再转化一次，这样保证接口一致
#define YUIKE_WEIBO_ID_TENC_STR @"yuiketech"
#define LIU_HAIFENG_ID_TENC 2// 程序内部再转化一次，这样保证接口一致
#define LIU_HAIFENG_ID_TENC_STR @"visualseawind"
#define EMPTY_WEIBO_ID_TENC 0
#define EMPTY_WEIBO_ID_TENC_STR @""

#define numEqual(num1,num2) (num1==num2)
#define strEqual(str1,str2) ([str1 isEqualToString: str2])
#define TENC_WEIBO_num2str(num) (numEqual(num,YUIKE_WEIBO_ID_TENC)?YUIKE_WEIBO_ID_TENC_STR:   (numEqual(num,LIU_HAIFENG_ID_TENC)?LIU_HAIFENG_ID_TENC_STR:EMPTY_WEIBO_ID_TENC_STR)   )
#define TENC_WEIBO_str2num(str) (strEqual(str,YUIKE_WEIBO_ID_TENC_STR)?YUIKE_WEIBO_ID_TENC:   (strEqual(str,LIU_HAIFENG_ID_TENC_STR)?LIU_HAIFENG_ID_TENC:EMPTY_WEIBO_ID_TENC)   )


#define DEF_didReceiveMemoryWarning DebugLog(@"======== didReceiveMemoryWarning ========"); DebugLog(@"getAvailableMegaBytes is: %f", [YkSystem getAvailableMegaBytes]);


/*
 设备的一些宏定义
 */
// 是否高清屏
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) || CGSizeEqualToSize(CGSizeMake(960, 640), [[UIScreen mainScreen] currentMode].size)): NO)

#define isPadRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(2048, 1536), [[UIScreen mainScreen] currentMode].size) ||  CGSizeEqualToSize(CGSizeMake(1536, 2048), [[UIScreen mainScreen] currentMode].size)): NO)
// 是否iPad
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
// 是否模拟器
#define isSimulator (NSNotFound != [[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location)

#define kMustOverrideMethod  [NSException raise:NSInternalInconsistencyException format:@"You must override Method:%@ in a subclass With Super Class:%@", NSStringFromSelector(_cmd), [[self class] description]];




/* 
 服务器路径宏定义
 */
#define _YIUKE_                                                 @"YIUKE"

#define _YUIKE_TEST_SERVER_ROOT_IP_                             @"192.168.1.66"
#define _YIUKE_TEST_SERVER_ROOT_URL_                            [NSString stringWithFormat:@"http://%@:8080", _YUIKE_TEST_SERVER_ROOT_IP_]  // 内部测试服务器

// 下面三个不要变，当这个 映射到本地文件系统的时候。。。你懂的
// for CacheFileSystem.h
#define _YUIKE_PUBLISH_SERVER_IP_              @"223.4.115.213"
#define _YUIKE_PUBLISH_SERVER_DOMAIN_          @"yuike.com"
#define _YUIKE_PUBLISH_SERVER_DOMAIN_DOT_      @".yuike.com"
#define _YUIKE_PUBLISH_SERVER_DOMAIN_WWW_      @"www.yuike.com"
#define _YUIKE_PUBLISH_SERVER_BY_IP_                 [NSString stringWithFormat:@"http://%@/dataroot/", _YUIKE_PUBLISH_SERVER_IP_]//            @"http://223.4.115.213/dataroot/"
#define _YUIKE_PUBLISH_SERVER_BY_DOMAIN_             [NSString stringWithFormat:@"http://%@/dataroot/", _YUIKE_PUBLISH_SERVER_DOMAIN_WWW_]//


/*
 taobao
 */
#define _TAOBAO_IMAGE_SERVER_DEMO_      @"taobaocdn.com"

#endif

